package com.mac.hosp_pre.sys.controller;


import com.mac.hosp_pre.reply.R;
import com.mac.hosp_pre.sys.model.LoginBody;
import com.mac.hosp_pre.sys.model.LoginUser;
import com.mac.hosp_pre.sys.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户管理
 * @author mac
 */
@Tag(name = "用户管理")
@RestController
@RequestMapping("/admin/sys/user/")
public class SysUserController {


    @Autowired
    private SysUserService sysUserService;

    @Operation(summary = "登陆接口")
    @PostMapping("/login")
    public R<LoginUser> login(@RequestBody LoginBody loginUser) {
        // 生成令牌
        LoginUser login = sysUserService.login(loginUser);
        return R.success(login);
    }

    @Operation(summary = "获取用户信息")
    @GetMapping("/getInfo")
    public R<LoginUser> getInfo() {
        // 生成令牌
        LoginUser user = sysUserService.getInfo();
        return R.success(user);
    }
}
